@ECHO OFF
%homedrive%
cd %~ps0

@ECHO OFF
cd %~ps0
for %%X in (java.exe) do (set JAVAFOUND=%%~$PATH:X)
for %%X in (python.exe) do (set PYTHONFOUND=%%~$PATH:X)

if defined PYTHONFOUND (
  echo Python was found
  copy pytivoservice.ini.python pytivoservice.ini
  goto end
)

if defined JAVAFOUND (
  echo JAVA was found
  copy pytivoservice.ini.java pytivoservice.ini
  goto end
)

echo Neither java or python was found.  Please install one!
pause

:end

echo WorkingDir=%homedrive%%~ps0 >> pytivoservice.ini

echo [%USERNAME%s Videos on %COMPUTERNAME%] >> pytivo.conf
echo path = %USERPROFILE%\Videos >> pytivo.conf
echo type = video >> pytivo.conf
echo. >> pytivo.conf

echo [%USERNAME%s Music on %COMPUTERNAME%] >> pytivo.conf
echo path = %USERPROFILE%\Music >> pytivo.conf
echo type = music >> pytivo.conf
echo. >> pytivo.conf

rem echo [%USERNAME%s Pictures on %COMPUTERNAME%] >> pytivo.conf
rem echo path = %USERPROFILE%\Pictures >> pytivo.conf
rem echo type = photo >> pytivo.conf
rem echo. >> pytivo.conf


pytivoservice -i
netsh advfirewall firewall add rule name=PyTivo dir=in action=allow enable=yes profile=any localport=9032 protocol=TCP
netsh advfirewall firewall add rule name=PyTivo dir=in action=allow enable=yes profile=any localport=2190 protocol=UDP
net start PyTivo
